﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace CPPProject.Migrations
{
    public partial class updatepartBin : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "CPPPartBin",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    TenantId = table.Column<int>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    PartNum = table.Column<string>(maxLength: 50, nullable: false),
                    Quantity = table.Column<decimal>(nullable: false),
                    OrgQty = table.Column<decimal>(nullable: false),
                    PlantId = table.Column<int>(nullable: false),
                    CompanyId = table.Column<long>(nullable: false),
                    ForCompanyId = table.Column<long>(nullable: true),
                    PType = table.Column<string>(maxLength: 10, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CPPPartBin", x => x.Id);
                    table.ForeignKey(
                        name: "FK_CPPPartBin_CPPCompany_CompanyId",
                        column: x => x.CompanyId,
                        principalTable: "CPPCompany",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_CPPPartBin_CPPCompany_ForCompanyId",
                        column: x => x.ForCompanyId,
                        principalTable: "CPPCompany",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateIndex(
                name: "IX_CPPPartBin_CompanyId",
                table: "CPPPartBin",
                column: "CompanyId");

            migrationBuilder.CreateIndex(
                name: "IX_CPPPartBin_ForCompanyId",
                table: "CPPPartBin",
                column: "ForCompanyId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "CPPPartBin");
        }
    }
}
